<%@ page import="org.jeecgframework.web.util.StaticValue" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:1px;">
   <input type="hidden" id="type" value="${type}"/>
  <t:datagrid name="cbsEquipmentApplyList" checkbox="true" fitColumns="false" title="备件审批管理" actionUrl="cbsEquipmentApplyController.do?datagridList" idField="id" fit="true" queryMode="group" onLoadSuccess="changeColor">
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="备件申请单号"  field="recordId"    queryMode="single"  width="120" query="true"></t:dgCol>
   <t:dgCol title="服务单号（CR）"  field="code"    queryMode="single"  width="120" query="true"></t:dgCol>
   <t:dgCol title="设备序列号"  field="sn"    queryMode="single"  width="120" query="true"></t:dgCol>
   <t:dgCol title="SR"  field="sr"    queryMode="single"  width="120" query="true"></t:dgCol>
   <t:dgCol title="SO"  field="so"    queryMode="single"  width="120" query="true"></t:dgCol>
   <t:dgCol title="备件类型"  field="typeDes"    queryMode="single"  width="150"></t:dgCol>
   <t:dgCol title="备件号"  field="item"    queryMode="single"  width="150" ></t:dgCol>
   <t:dgCol title="备件数量"  field="total"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="申请优先级"  field="applyLayer" dictionary="<%=StaticValue.apply_layer %>"   queryMode="single"  width="120" query="true"></t:dgCol>
   <t:dgCol title="申请人"  field="createName"    queryMode="single"  width="90"></t:dgCol>
   <t:dgCol title="申请时间"  field="createDate"  formatter="yyyy-MM-dd hh:mm"  queryMode="group"  width="120" query="true"></t:dgCol>
   <t:dgCol title="申请状态"  field="status" dictionary="<%=StaticValue.State_Of_Approval %>" query="true"  queryMode="single"  width="120"></t:dgCol>
   <%--<t:dgCol title="详细地址"  field="address"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="仓库ID"  field="warehouseId"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="申请理由"  field="applyReason"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="备注"  field="memo"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="状态"  field="status"    queryMode="single"  width="120" dictionary="<%=StaticValue.State_Of_Approval %>"></t:dgCol>
   <t:dgCol title="审批人"  field="approveUser" hidden="true"   queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创建人名称"  field="createName"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创建人登录名称"  field="createBy"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创建日期"  field="createDate" formatter="yyyy-MM-dd" hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="更新人名称"  field="updateName"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="更新人登录名称"  field="updateBy"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="更新日期"  field="updateDate" formatter="yyyy-MM-dd" hidden="true"  queryMode="single"  width="120"></t:dgCol>--%>
   <%--   <t:dgCol title="操作" field="opt" width="100"></t:dgCol>

      <t:dgDelOpt title="删除" url="cbsEquipmentApplyController.do?doDel&id={id}" />
   --%>
   <%--<t:dgToolBar title="录入" icon="icon-add" url="cbsEquipmentApplyController.do?goAdd" funname="add"></t:dgToolBar>--%>
   <%--<t:dgToolBar title="编辑" icon="icon-edit" url="cbsEquipmentApplyController.do?goUpdate" funname="update"></t:dgToolBar>--%>
   <t:dgToolBar title="编辑" icon="icon-edit" funname="update" operationCode="equipmentupdate"></t:dgToolBar>
<%--
   <t:dgToolBar title="批量删除"  icon="icon-remove" url="cbsEquipmentApplyController.do?doBatchDel" funname="deleteALLSelect"></t:dgToolBar>
--%>
   <%--<t:dgToolBar title="查看" icon="icon-search" url="cbsEquipmentApplyController.do?goUpdate" funname="detail"></t:dgToolBar>--%>
   <%--<t:dgToolBar title="导入" icon="icon-put" funname="ImportXls"></t:dgToolBar>--%>
   <t:dgToolBar title="导出" icon="icon-putout" funname="ExportXls" operationCode="equipmentputout"></t:dgToolBar>
   <%--<t:dgToolBar title="模板下载" icon="icon-putout" funname="ExportXlsByT"></t:dgToolBar>--%>
  </t:datagrid>
  </div>
 </div>
 <script type="text/javascript">
 $(document).ready(function(){
     //给时间控件加上样式
     $("#cbsEquipmentApplyListtb").find("input[name='createDate_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
         WdatePicker({dateFmt: 'yyyy-MM-dd'});
     });
     $("#cbsEquipmentApplyListtb").find("input[name='createDate_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
         WdatePicker({dateFmt: 'yyyy-MM-dd'});
     });
     var type = $("#type").val();
     if(type == "add"){
         tip("添加成功");
     }else if(type == "1"){
         tip("更新成功");
     }else if(type == "2"){
         tip("操作成功");
     }
 		//给时间控件加上样式
 			$("#cbsEquipmentApplyListtb").find("input[name='createDate']").attr("class","Wdate").attr("style","height:20px;width:90px;").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
 			$("#cbsEquipmentApplyListtb").find("input[name='updateDate']").attr("class","Wdate").attr("style","height:20px;width:90px;").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
 });
 
//导入
function ImportXls() {
	openuploadwin('Excel导入', 'cbsEquipmentApplyController.do?upload', "cbsEquipmentApplyList");
}

//导出
function ExportXls() {
    var currPageRows = $("#cbsEquipmentApplyList").datagrid("getRows");
    var idsData = [];
    $(currPageRows).each(function (i, rowData) {
        idsData.push(rowData.id);
    });
    if (idsData.length > 0) {
        myDownload("cbsEquipmentApplyController.do?exportEquipmentXls", "planIds=" + idsData.join(","));
    } else {
        tip("当前页面没有数据可以导出");
    }
	//JeecgExcelExport("cbsEquipmentApplyController.do?exportEquipmentXls","cbsEquipmentApplyList");
}

//模板下载
function ExportXlsByT() {
	JeecgExcelExport("cbsEquipmentApplyController.do?exportXlsByT","cbsEquipmentApplyList");
}
 function update() {
     var datas = $("#cbsEquipmentApplyList").datagrid("getSelections");
     if(datas.length != 1){
         tip("请选择一条申请单");
         return;
     }
     var id = datas[0].id;
     var recordId = datas[0].recordId;
     addOneTab('备件申请详情页'+recordId, 'cbsEquipmentApplyController.do?goApplyDetail&id='+id, '');
 }
 
 /*未审批的文字为红色*/
 function changeColor() {
     var trs = $("#cbsEquipmentApplyList").prev().find('div.datagrid-body').find('tr');
     for (var i = 0; i < trs.length; i++) {
             if (trs[i].cells[12].firstChild.innerHTML =='未审批')
                 trs[i].cells[12].style.cssText = 'color:red';
         
     }
 }
 </script>